import requests
import json
from flask import current_app


def get_weahter_cache(conn, city):
    key = 'weahter:%s' % city
    json_bytes = conn.get(key)
    if not json_bytes:
        params = {'cityName': city}
        json_bytes = requests.get(current_app.config['WEATHER_URL'], params=params).content
        conn.set(key, json_bytes, ex=3600)
    return json.loads(json_bytes)









